package com.yumi.aop;

import org.aspectj.lang.JoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

public class LoggerAspect {
    //日志记录对象
    private static final Logger LOGGER = LoggerFactory.getLogger(LoggerAspect.class);
    /**
     * 前置增强-打印进入方法和参数
     */
    public void before(JoinPoint jp){
        LOGGER.info("方法：{}，参数：{}",jp.getTarget(),jp.getSignature().getName(), Arrays.toString(jp.getArgs()));
    }
    /**
     * 后置增强-打印方法返回值
     */
    public void afterReturning(JoinPoint jp,Object result ){
        LOGGER.info("方法{}返回：{}",jp.getTarget(),jp.getSignature().getName(),result);
    }
}
